package com.bcdat.bcdatbrace.bcdatEsSearch.controller;


import com.bcdat.bcdatbrace.bcdatEsSearch.document.ProductDocument;
import com.bcdat.bcdatbrace.bcdatEsSearch.service.EsSearchService;
import com.bcdat.bcdatbrace.utils.vo.ResultVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;

/**
 * elasticsearch 操作功能
 * @author lsy
 * @version 0.1
 * @date 2019/09/30 15:09
 */
@RestController
@RequestMapping("/es_search_controller")
public class EsSearchController {
    private Logger log = LoggerFactory.getLogger(getClass());

    @Resource
    private EsSearchService esSearchService;


    /**
     * 清空索引
     * @return
     */
    @RequestMapping("/delete_all")
    public Object deleteAll() {
        return esSearchService.deleteAll();
    }


    /**
     * 根据获取全部
     * @return
     */
    @RequestMapping("/get_all")
    public ResultVO getAll(){
        return esSearchService.getAll();
    }



    /**
     * 新增 产品实体类
     * @return
     */
    @RequestMapping("/add_product_document")
    public Object addProductDocument(@RequestBody ProductDocument productDocument){
        return esSearchService.addProductDocument(productDocument);
    }

    /**
     * 根据ID获取
     * @return
     */
    @RequestMapping("/get")
    public Object getById(@RequestBody Map map){
        return esSearchService.getById(map);
    }


    /**
     * 根据ID删除索引
     * @return
     */
    @RequestMapping("/delete")
    public ResultVO delete(@RequestBody Map map) {
        return esSearchService.delete(map);
    }
}
